package com.day0921;

public class Text2 {
    public void add(int num1,int num2){
        num1 = 10;
        System.out.println("num1：" + num1);
        num2 = 20;
        System.out.println("num2：" + num2);
        int sum = num1 + num2;
        System.out.println("sum：" + sum);
    }
    public void add(Num num){
        num.num1 = 10;
        num.num2 = 20;
        System.out.println(num.num1);
        System.out.println(num.num2);
    }

    public static void main(String[] args) {
//        值传递  引用传递   参数类型
//        Java中只用值传递
//      基本数据类型   传参的时候  传值
        Text2 text2 = new Text2();
        //值传递
        int num1 = 14;
        int num2 = 12;
        text2.add(num1,num2);
        System.out.println("num1：" + num1);
        System.out.println("num2：" + num2);

        //引用传递
        Num num  = new Num();
        num.num1 = 1;
        num.num2 = 2;
        text2.add(num);
        System.out.println(num.num1);
        System.out.println(num.num2);
    }
}
